package com.chat.rabbitmq.producer;

import com.chat.constans.MqConstants;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageConst;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 生产者测试
 *
 * @author mhw
 * @version v1.0
 * @date 2019-11-15
 */
@Component
@Slf4j
public class TestProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendToTestQueue(String msgJSON) {
        log.info("消息生产者，发送数据到测试队列，内容：【{}】", msgJSON);

        Message<String> message = MessageBuilder
                .withPayload(msgJSON)
                .setHeader(MessageConst.PROPERTY_TAGS,"ticketOrder")
                .build();

//        rocketMQTemplate.send(MqConstants.EXCHANGE_TEST,message);
    }
}
